# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=matplotlib
pkgbase=mingw-w64-python2-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=2.2.4
pkgrel=1
pkgdesc="A python plotting library, making publication quality plots (mingw-w64)"
arch=('any')
url='https://matplotlib.org/'
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-python2-pytz"
         "${MINGW_PACKAGE_PREFIX}-python2-numpy"
         "${MINGW_PACKAGE_PREFIX}-python2-cairo"
         "${MINGW_PACKAGE_PREFIX}-python2-cycler"
         "${MINGW_PACKAGE_PREFIX}-python2-pyqt5"
         "${MINGW_PACKAGE_PREFIX}-python2-dateutil"
         "${MINGW_PACKAGE_PREFIX}-python2-pyparsing"
         "${MINGW_PACKAGE_PREFIX}-python2-kiwisolver"
         "${MINGW_PACKAGE_PREFIX}-python2-backports.functools_lru_cache"
         "${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         #"${MINGW_PACKAGE_PREFIX}-qhull"
         )
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/matplotlib/matplotlib/archive/v${pkgver}.tar.gz"
        setupext.py.patch
        setup.py.patch)
sha256sums=('601a3bf5c1b08710edbe00347d97619f43f2d1edcd7aa94119ff837e6327c7f7'
            'b9e2e6346f6941478642b99c844fd0b7f01ce2ff9bbfdbf92c2c3a823733edac'
            '2ace7d4fe23ba9e96f2c81f827c8ea6bc65c532e6bd4eee3a655aae1ae6dab17')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i ${srcdir}/setupext.py.patch
  patch -p1 -i ${srcdir}/setup.py.patch
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install -O1 --skip-build \
    --root="${pkgdir}" --prefix=${MINGW_PREFIX}

  install -Dm644 doc/users/license.rst "${pkgdir}${MINGW_PREFIX}"/share/licenses/python2-matplotlib/LICENSE
}
